<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 5.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha256-xejo6yLi6vGtAjcMIsY8BHdKsLg7QynVlFMzdQgUuy8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"gz1234.gitee.io","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.12.3","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"flat"},"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="包结构规范 (1.1)简介该文档主要的设计目标是商业体系前端资源分包进行约定规范，使开发资源容易被共享和复用。 编撰李玉北、erik、黄后锦、王杨、张立理、赵雷。 本文档由商业运营体系前端技术组审校发布。 要求在本文档中，使用的关键字会以中文+括号包含的关键字英文表示：必须(MUST)。关键字”MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”,">
<meta property="og:type" content="website">
<meta property="og:title" content="郭泽">
<meta property="og:url" content="https://gz1234.gitee.io/spec-master/package.html">
<meta property="og:site_name" content="郭泽">
<meta property="og:description" content="包结构规范 (1.1)简介该文档主要的设计目标是商业体系前端资源分包进行约定规范，使开发资源容易被共享和复用。 编撰李玉北、erik、黄后锦、王杨、张立理、赵雷。 本文档由商业运营体系前端技术组审校发布。 要求在本文档中，使用的关键字会以中文+括号包含的关键字英文表示：必须(MUST)。关键字”MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”,">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-05-31T00:57:28.725Z">
<meta property="article:modified_time" content="2023-05-31T00:57:28.725Z">
<meta property="article:author" content="郭泽">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://gz1234.gitee.io/spec-master/package">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":false,"lang":"zh-CN","comments":true,"permalink":"https://gz1234.gitee.io/spec-master/package.html","path":"spec-master/package.html","title":""}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title> | 郭泽
</title>
  





  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">郭泽</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%8C%85%E7%BB%93%E6%9E%84%E8%A7%84%E8%8C%83-1-1"><span class="nav-number">1.</span> <span class="nav-text">包结构规范 (1.1)</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%AE%80%E4%BB%8B"><span class="nav-number">1.1.</span> <span class="nav-text">简介</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%BC%96%E6%92%B0"><span class="nav-number">1.1.1.</span> <span class="nav-text">编撰</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A6%81%E6%B1%82"><span class="nav-number">1.1.2.</span> <span class="nav-text">要求</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%A7%84%E8%8C%83%E8%AF%B4%E6%98%8E%E7%BA%A6%E5%AE%9A"><span class="nav-number">1.1.3.</span> <span class="nav-text">规范说明约定</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8C%85%E5%BC%80%E5%8F%91%E8%AF%B4%E6%98%8E"><span class="nav-number">1.1.4.</span> <span class="nav-text">包开发说明</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E5%8C%85%E5%AE%9A%E4%B9%89"><span class="nav-number">1.1.4.1.</span> <span class="nav-text">包定义</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%A8%A1%E5%9D%97%E5%AE%9A%E4%B9%89"><span class="nav-number">1.1.4.2.</span> <span class="nav-text">模块定义</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BE%9D%E8%B5%96%E7%AE%A1%E7%90%86"><span class="nav-number">1.1.4.3.</span> <span class="nav-text">依赖管理</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%B5%84%E6%BA%90"><span class="nav-number">1.1.5.</span> <span class="nav-text">资源</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8C%85%E6%8F%8F%E8%BF%B0%E6%96%87%E4%BB%B6"><span class="nav-number">1.2.</span> <span class="nav-text">包描述文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BF%85%E9%80%89%E5%AD%97%E6%AE%B5"><span class="nav-number">1.2.1.</span> <span class="nav-text">必选字段</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%AF%E9%80%89%E5%AD%97%E6%AE%B5"><span class="nav-number">1.2.2.</span> <span class="nav-text">可选字段</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B"><span class="nav-number">1.2.3.</span> <span class="nav-text">示例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8C%85%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><span class="nav-number">1.3.</span> <span class="nav-text">包目录结构</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B-1"><span class="nav-number">1.3.1.</span> <span class="nav-text">示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#package-json"><span class="nav-number">1.3.2.</span> <span class="nav-text">package.json</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#src"><span class="nav-number">1.3.3.</span> <span class="nav-text">src</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#dep"><span class="nav-number">1.3.4.</span> <span class="nav-text">dep</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="nav-number">1.3.5.</span> <span class="nav-text">参考资料</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">郭泽</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">54</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">21</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">51</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner page posts-expand">


    
    
    
    <div class="post-block" lang="zh-CN"><header class="post-header">

<h1 class="post-title" itemprop="name headline">
</h1>

<div class="post-meta-container">
</div>

</header>

      
      
      <div class="post-body">
          <h1 id="包结构规范-1-1"><a href="#包结构规范-1-1" class="headerlink" title="包结构规范 (1.1)"></a>包结构规范 (1.1)</h1><h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>该文档主要的设计目标是商业体系<code>前端</code>资源分包进行约定规范，使开发资源容易被共享和复用。</p>
<h3 id="编撰"><a href="#编撰" class="headerlink" title="编撰"></a>编撰</h3><p>李玉北、erik、黄后锦、王杨、张立理、赵雷。</p>
<p>本文档由<code>商业运营体系前端技术组</code>审校发布。</p>
<h3 id="要求"><a href="#要求" class="headerlink" title="要求"></a>要求</h3><p>在本文档中，使用的关键字会以中文+括号包含的关键字英文表示：必须(MUST)。关键字”MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”被定义在rfc2119中。</p>
<h3 id="规范说明约定"><a href="#规范说明约定" class="headerlink" title="规范说明约定"></a>规范说明约定</h3><p>以下规范文档中，以<code>$&#123;root&#125;</code>表示包的根目录。</p>
<h3 id="包开发说明"><a href="#包开发说明" class="headerlink" title="包开发说明"></a>包开发说明</h3><h4 id="包定义"><a href="#包定义" class="headerlink" title="包定义"></a>包定义</h4><p><code>包</code>是实现某个独立功能，有复用价值的代码集。在具体的实现过程中， <em>必须(MUST)</em> 按照<a href="module.text">模块和加载器规范</a>来开发和管理模块。</p>
<h4 id="模块定义"><a href="#模块定义" class="headerlink" title="模块定义"></a>模块定义</h4><p><code>包</code>中的模块定义时 <em>必须(MUST)</em> 采用匿名id<code>define( factory )</code>进行定义， <em>不允许(MUST NOT)</em> 使用<code>define( moduleId, factory )</code>。</p>
<h4 id="依赖管理"><a href="#依赖管理" class="headerlink" title="依赖管理"></a>依赖管理</h4><p><code>包</code>中的模块对其他模块的依赖分成两种：<code>内部模块依赖</code>和<code>外部包依赖</code>。下面是关于模块依赖的管理说明：</p>
<ol>
<li>对<code>内部模块依赖</code>的情况， <em>必须(MUST)</em> 保证内部模块id与路径的对应关系。require依赖引用 <em>必须(MUST)</em> 使用<code>relative id</code>， <em>不允许(MUST NOT)</em> 使用<code>top-level id</code>。</li>
<li>对<code>外部包依赖</code>的情况，require依赖引用 <em>必须(MUST)</em> 使用<code>top-level id</code>。</li>
</ol>
<p>开发时，我们通常会做一些测试用例或示例，此时需要通过AMD Loader将当前包粘合到页面环境，并使其可运行。这时我们需要遵守一些规则：</p>
<ol>
<li>对<code>内部模块依赖</code>，AMD Loader配置 <em>推荐(RECOMMENDED)</em> 通过<code>packages</code>将<code>location</code>配置到<code>$&#123;root&#125;</code>下的<code>src</code>目录， <em>不允许(MUST NOT)</em> 通过<code>paths</code>进行路径映射。</li>
<li>对<code>外部包依赖</code>，请参照<a href="directory.md">项目目录结构规范</a>将相关依赖包导入，并且 <em>必须(MUST)</em> 通过<code>packages</code>项配置AMD Loader。</li>
</ol>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 示例：ER package的test配置</span></span><br><span class="line"><span class="built_in">require</span>.config(&#123;</span><br><span class="line">    packages: [</span><br><span class="line">        &#123;</span><br><span class="line">            name: <span class="string">&#x27;er&#x27;</span>,</span><br><span class="line">            location: <span class="string">&#x27;../src&#x27;</span>,</span><br><span class="line">            main: <span class="string">&#x27;main&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            name: <span class="string">&#x27;mini-event&#x27;</span>,</span><br><span class="line">            location: <span class="string">&#x27;../dep/mini-event/1.0.0/src&#x27;</span>,</span><br><span class="line">            main: <span class="string">&#x27;main&#x27;</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            name: <span class="string">&#x27;etpl&#x27;</span>,</span><br><span class="line">            location: <span class="string">&#x27;../dep/etpl/2.0.2/src&#x27;</span>,</span><br><span class="line">            main: <span class="string">&#x27;main&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    ]</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>

<h3 id="资源"><a href="#资源" class="headerlink" title="资源"></a>资源</h3><p><em>允许(SHALL)</em> 包含如下类型的资源：</p>
<p>脚本, 样式以及样式相关图片, 直接引用图片, html, 模板, 文档, 测试套件。</p>
<h2 id="包描述文件"><a href="#包描述文件" class="headerlink" title="包描述文件"></a>包描述文件</h2><p>包描述文件 <em>必须(MUST)</em> 置于<code>$&#123;root&#125;</code>下，命名为package.json， <em>必须(MUST)</em> 是一个UTF-8编码的严格JSON格式的文本文件。</p>
<h3 id="必选字段"><a href="#必选字段" class="headerlink" title="必选字段"></a>必选字段</h3><ul>
<li><code>name</code>: 包名。 <em>必须(MUST)</em> 为由camel命名法产生的字母组成的字符串。</li>
<li><code>version</code>: 版本号。版本号 <em>必须(MUST)</em> 为字符串，需要符合<a target="_blank" rel="noopener" href="http://semver.org/">SemVer</a>的格式约定。</li>
<li><code>maintainers</code>: 维护者列表。该字段 <em>必须(MUST)</em> 是一个数组，数组中每项 <em>必须(MUST)</em> 包含维护者的名称字段”name”与电子邮件字段”email”。</li>
</ul>
<h3 id="可选字段"><a href="#可选字段" class="headerlink" title="可选字段"></a>可选字段</h3><ul>
<li><code>main</code>: 模块名，用来说明当前<code>包</code>的入口文件。如果包名为<code>foo</code>，那么执行<code>require(&quot;foo&quot;)</code>的时候，返回的内容就是当前模块<code>exports</code>的内容。</li>
<li><code>description</code>: 描述信息。 <em>必须(MUST)</em> 为字符串。</li>
<li><code>dependencies</code>: 依赖声明。该字段 <em>必须(MUST)</em> 是一个<code>JSON Object</code>，其中<code>key</code>为依赖的包名，<code>value</code>为版本号，支持如下的格式：<ul>
<li><code>version</code></li>
<li><code>&gt;version</code></li>
<li><code>&gt;=version</code></li>
<li><code>&lt;version</code></li>
<li><code>&lt;=version</code></li>
<li><code>*</code>: 任意版本</li>
</ul>
</li>
<li><code>devDependencies</code>: 类似<code>dependencies</code>的角色，但不是当前<code>包</code>必须的，只是在开发和调试的时候一些依赖的内容。</li>
<li><code>contributors</code>: 贡献者列表。该字段 <em>必须(MUST)</em> 是一个数组，数组中每项 <em>必须(MUST)</em> 包含维护者的名称字段<code>name</code>与电子邮件字段<code>email</code>。</li>
<li><code>homepage</code>: 该字段 <em>必须(MUST)</em> 为URL格式的字符串。</li>
</ul>
<h3 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h3> <figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="string">&quot;name&quot;</span>: <span class="string">&quot;zrender&quot;</span>,</span><br><span class="line">    <span class="string">&quot;version&quot;</span>: <span class="string">&quot;0.0.1&quot;</span>,</span><br><span class="line">    <span class="string">&quot;maintainers&quot;</span>: [</span><br><span class="line">        &#123;<span class="string">&quot;name&quot;</span>: <span class="string">&quot;foo&quot;</span>, <span class="string">&quot;email&quot;</span>: <span class="string">&quot;foo@baidu.com&quot;</span>&#125;,</span><br><span class="line">        &#123;<span class="string">&quot;name&quot;</span>: <span class="string">&quot;bar&quot;</span>, <span class="string">&quot;email&quot;</span>: <span class="string">&quot;bar@baidu.com&quot;</span>, <span class="string">&quot;url&quot;</span>: <span class="string">&quot;http://www.baidu.com/bar&quot;</span>&#125;</span><br><span class="line">    ],</span><br><span class="line">    <span class="string">&quot;dependencies&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;foo&quot;</span>: <span class="string">&quot;0.0.1&quot;</span>,</span><br><span class="line">        <span class="string">&quot;bar&quot;</span>: <span class="string">&quot;*&quot;</span></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="string">&quot;devDependencies&quot;</span>: &#123;</span><br><span class="line">        <span class="string">&quot;uglify-js&quot;</span>: <span class="string">&quot;*&quot;</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h2 id="包目录结构"><a href="#包目录结构" class="headerlink" title="包目录结构"></a>包目录结构</h2><h3 id="示例-1"><a href="#示例-1" class="headerlink" title="示例"></a>示例</h3><pre><code>$&#123;root&#125;/
    package.json
    README.md
    src/
        css/[?]
        img/
        main.js
    dep/
        foo/
        bar/
        jquery/
        tangram/
        mustache/
        ...
    test/
    doc/</code></pre>
<h3 id="package-json"><a href="#package-json" class="headerlink" title="package.json"></a>package.json</h3><p><code>package.json</code> <em>必须(MUST)</em> 直接放在包顶层目录<code>$&#123;root&#125;</code>中。</p>
<h3 id="src"><a href="#src" class="headerlink" title="src"></a>src</h3><p>按照通常的理解，一个<code>包项目</code>不应该特别复杂。下面是一个简单的例子，详细的目录划分方法和原则请参考 <a href="directory.md">项目目录结构规范</a> 。</p>
<pre><code>$&#123;root&#125;/
    src/
        main.js
        Control.js
        Button.js
        css/
            button.css
    package.json
    README.md</code></pre>
<h3 id="dep"><a href="#dep" class="headerlink" title="dep"></a>dep</h3><p>用来存放<code>dependencies package</code>的代码， <em>不允许(MUST NOT)</em> 放置任何其它的内容。</p>
<h3 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h3><ol>
<li><a target="_blank" rel="noopener" href="https://npmjs.org/doc/json.html">https://npmjs.org/doc/json.html</a></li>
<li><a target="_blank" rel="noopener" href="http://twitter.github.com/bower/">http://twitter.github.com/bower/</a></li>
<li><a target="_blank" rel="noopener" href="http://yeoman.io/">http://yeoman.io/</a></li>
<li><a target="_blank" rel="noopener" href="http://semver.org/">http://semver.org/</a></li>
</ol>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
      </div>
      
      
      
    </div>

    
    


</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">郭泽</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/bookmark.js"></script>

  
<script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.0/search.js" integrity="sha256-vXZMYLEqsROAXkEw93GGIvaB2ab+QW6w3+1ahD9nXXA=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>

  <script class="next-config" data-name="pdf" type="application/json">{"object_url":{"url":"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.2.8/pdfobject.min.js","integrity":"sha256-tu9j5pBilBQrWSDePOOajCUdz6hWsid/lBNzK4KgEPM="},"url":"/lib/pdf/web/viewer.html"}</script>
  <script src="/js/third-party/tags/pdf.js"></script>

  <script class="next-config" data-name="mermaid" type="application/json">{"enable":true,"theme":{"light":"default","dark":"dark"},"js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.1.3/mermaid.min.js","integrity":"sha256-TIYL00Rhw/8WaoUhYTLX9SKIEFdXxg+yMWSLVUbhiLg="}}</script>
  <script src="/js/third-party/tags/mermaid.js"></script>

  <script src="/js/third-party/fancybox.js"></script>


  





</body>
</html>
